
const con = require('../utils/myconn.js')

exports.getAllpost = function (data, callback) {

    // 查询数据
    let sql = `SELECT posts.*,categories.name,users.nickname 
    FROM posts 
    JOIN users ON posts.user_id=users.id
    JOIN categories ON posts.category_id=categories.id
    order by id desc
    limit ${(data.pageNum - 1) * data.pageSize},${data.pageSize}`
    con.query(sql, (err, resluts) => {
        if (err) {
            callback(err)
        } else {
            callback(null, resluts)
        }

    })

}